package com.example.administrator.zhongyichou.fragment;

import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.example.administrator.zhongyichou.activity.IHelpedActivity;
import com.example.administrator.zhongyichou.activity.LoginActivity;
import com.example.administrator.zhongyichou.activity.MutualMembersActivity;
import com.example.administrator.zhongyichou.activity.MyBankActivity;
import com.example.administrator.zhongyichou.activity.MyLaunchActivity;
import com.example.administrator.zhongyichou.Bean.BaseEventBean;
import com.example.administrator.zhongyichou.base.BaseFragment;
import com.example.administrator.zhongyichou.base.MyApplication;
import com.example.administrator.zhongyichou.config.Constants;
import com.example.administrator.zhongyichou.net.core.HttpLoader;
import com.example.administrator.zhongyichou.net.protocol.GsonBaseProtocol;
import com.example.administrator.zhongyichou.R;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 第五版新加
 * Created by lichenyu on 2017/11/20.
 * 描述：我的
 */

public class MyFragment extends BaseFragment {
    @BindView(R.id.img_avatar)
    ImageView imgAvatar;
    @BindView(R.id.txt_login)
    TextView txtLogin;
    @BindView(R.id.ll_btn1)
    LinearLayout llBtn1;
    @BindView(R.id.ll_btn2)
    LinearLayout llBtn2;
    @BindView(R.id.ll_btn3)
    LinearLayout llBtn3;
    @BindView(R.id.ll_btn4)
    LinearLayout llBtn4;
    @BindView(R.id.ll_btn5)
    LinearLayout llBtn5;
    @BindView(R.id.ll_btn6)
    LinearLayout llBtn6;
    @BindView(R.id.btn_exit)
    Button btnExit;

    @Override
    protected void responseData(GsonBaseProtocol mGsonBaseProtocal) {

    }

    @Override
    protected HttpLoader initHttpLoader() {
        return null;
    }

    @Override
    protected View initContentView() {
        View view = LayoutInflater.from(getActivity()).inflate(R.layout.my_fragment, null);
        ButterKnife.bind(this, view);
        boolean fist_login = MyApplication.getSPValue(Constants.KEY_HAS_LOGIN, true);
        if (!fist_login) {
            txtLogin.setText(MyApplication.getSPValue(Constants.USER_PHONE, ""));
        }
        return view;
    }

    @Override
    public boolean onEventBus(BaseEventBean baseEventBean) {

        return false;
    }

    @OnClick({R.id.img_avatar, R.id.txt_login, R.id.ll_btn1, R.id.ll_btn2, R.id.ll_btn3, R.id.ll_btn4, R.id.ll_btn5, R.id.ll_btn6, R.id.btn_exit})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.img_avatar://头像
                break;
            case R.id.txt_login://登录注册
                break;
            case R.id.ll_btn1://互助会员
                Intent intent1 = new Intent(getActivity(), MutualMembersActivity.class);
                startActivity(intent1);
                break;
            case R.id.ll_btn2://发起项目
                Intent intent2 = new Intent(getActivity(), MyLaunchActivity.class);
                startActivity(intent2);
                break;
            case R.id.ll_btn3://我帮助过
                Intent intent3 = new Intent(getActivity(), IHelpedActivity.class);
                startActivity(intent3);
                break;
            case R.id.ll_btn4://我的银行
                Intent intent4 = new Intent(getActivity(), MyBankActivity.class);
                startActivity(intent4);
                break;
            case R.id.ll_btn5://筹款秘籍
                break;
            case R.id.ll_btn6://关注公益筹微信公众号
                break;
            case R.id.btn_exit://退出登录
                MyApplication.putSP(Constants.KEY_HAS_LOGIN, true);
                Intent intent = new Intent(getActivity(), LoginActivity.class);
                startActivity(intent);
                getActivity().finish();
                break;
        }
    }
}
